#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include<queue>
using namespace std;
#define MAXL 20
struct jd
{
	int v, w;
};
//jd a[MAXL];
struct node {
	int dis, u;

	bool operator>(const node& a) const { return dis > a.dis; }
};
vector<jd>a[MAXL];
//int dis[MAXL], vis[MAXL];!!!!!!!!!!
vector<int>dis(MAXL, 0x3fffff), vis(MAXL, 0);
priority_queue<node, vector<node>, greater<node> > q;
void dijk(int n,int s)
{
	//memset(dis, 0x3ffffff, sizeof(dis));
	dis[s] = 0;
	q.push({ 0,s });
	while (!q.empty())
	{
		int u = q.top().u;
		q.pop();
		if(vis[u])
			continue;
		vis[u] = 1;
		for (auto ed:a[u])
		{
			int  v, w;
			v = ed.v;
			w = ed.w;
			if (dis[v] > dis[u] + w)
			{
				dis[v] = dis[u] + w;
				q.push({dis[v],v});//
			}
		}
	}
}
signed  main()
{
	int n, w;
	cin >> n >> w;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			int s;
			cin >> s;
			if (s < w)
			{
				a[i].push_back({ j,s });
			}
		}
	}
	dijk(n, n);
	for (int i = 1; i <= n; i++)
	{
		cout << dis[i] << ' ';
	}
	cout << endl;
	return 0;
}